BinTree Insert( BinTree BST, ElementType X ){
		if(BST==NULL){
			BST=(BinTree)malloc(sizeof(struct TNode));
			BST->Data=X;
			BST->Left=BST->Right=NULL;
			return BST;
		}
		else if(X==BST->Data)  return BST;
		else if(X<BST->Data) {
			BST->Left=Insert(BST->Left,X);
			return BST;
		}
		else{
			BST->Right=Insert(BST->Right,X);
			return BST;
		}
}
BinTree Delete( BinTree BST, ElementType X ){
	BinTree Tmp;
	if(BST==NULL){
			printf("Not Found\n");
			return BST;
		}
			if(X<BST->Data){
				BST->Left=Delete(BST->Left,X);
			}
			else if(X>BST->Data){
			 	BST->Right=Delete(BST->Right,X);
			} 
			else{
				if (BST->Left&&BST->Right){
					Tmp = FindMin(BST->Right);
					BST->Data = Tmp->Data;
					BST->Right=Delete(BST->Right,Tmp->Data);
					}
				else {
						Tmp = BST;
						if (!BST->Left)
							BST = BST->Right;
						else
							BST = BST->Left;
					free(Tmp);
				}
			}
			return BST;
}
Position Find( BinTree BST, ElementType X ){
	if(BST==NULL) return NULL;
	if(BST->Data==X) return BST;
	else if(X<BST->Data) return Find(BST->Left,X);
	else return Find(BST->Right,X);
}
Position FindMin( BinTree BST ){
	if(BST==NULL) return NULL;
	while(BST->Left!=NULL){
		BST=BST->Left;
	}
	return BST;
}
Position FindMax( BinTree BST ){
	if(BST==NULL) return NULL;
	while(BST->Right!=NULL){
		BST=BST->Right;
	}
	return BST;
}
